home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS04.ADF / C / geltools.c < prev    next >
C/C++ Source or Header  |  1985-11-03  |  26KB  |  644 lines

  1.  
  2. /* geltools.c */
  3.  
  4. /* NOTE:  don't try to use vsprites until system software V1.1 becomes
  5.    available.  This tool works to do bobs, but not vsprites until 1.1.
  6.    
  7.    (system bug corrected).
  8.  
  9. */
  10.  
  11. /*
  12. author:  Rob Peck  9/85.  Will eventually cover AnimObs and AnimComps
  13.                           but not yet.
  14.          also note that NewGelList can be merged directly into
  15.          ReadyGels (next version will do so).  No need to have
  16.          separate.
  17.  
  18. */
  19. /* ***********************************************************************
  20.    this file is a collection of tools which are used with the vsprite and
  21.    bob software.  It contains the following:
  22.  
  23.         ReadyGels( *gelsinfo, *rastport )
  24.         NewGelList( *gelsinfo )
  25.         PurgeGels( *gelsinfo )
  26.  
  27.         struct Bob MakeBob(bitwidth,lineheight,imagedepth,*image,pfdepth,
  28.                         planePick,planeOnOff,x,y)
  29.         DeleteBob( &Bob );
  30.  
  31.         struct VSprite MakeVSprite(lineheight,*image,*colorset,x,y,
  32.                 width,imagedepth,flags);       
  33.         DeleteVSprite( &VSprite );
  34.  
  35.  
  36.    ReadyGels sets up the defaults of the gel system by initializing the        
  37.         GelsInfo structure you provide.  It uses information in your
  38.         RastPort structure to establish boundary collision defaults at
  39.         the outer edges of the raster.  It also links together the 
  40.         GelsInfo and the RastPort which you provide.
  41.  
  42.    NewGelList allocates space for two dummy virtual sprite structures
  43.         and calls InitGels.   You must already have run LoadView and
  44.         ReadyGels before NewGelList is called.  
  45.  
  46.    PurgeGels deallocates all memory which ReadyGels and NewGelList have
  47.         allocated.  The system will crash if you have not used these
  48.         routines to allocate the space (you cant deallocate something
  49.         which you havent allocated in the first place).
  50.  
  51.    MakeVSprite allocates enough space for and inits a normal vsprite.
  52.    DeleteVSprite deallocates the memory it used.
  53.  
  54.    MakeBob initializes a standard bob and allocates as much memory as is needed
  55.         for a normal bob and its vsprite structure, links them together.
  56.         To find the associated vsprite, look at the back-pointer (see the
  57.         routine doc itself).
  58.    DeleteBob deallocates the memory it used.
  59.  
  60. *******************************************************************  */
  61.  
  62.  
  63.  
  64. /* user passes a pointer to his GelsInfo structure which he wants to init, 
  65.    along with a pointer to his IVPArgs.  Default init places the topmost
  66.    bottommost etc at the outermost boundaries of the users rastport parameters
  67.     */
  68.  
  69. ReadyGels(g, r)  
  70. struct RastPort *r;
  71. struct GelsInfo *g;
  72. {
  73.  
  74. WORD *lastcolors;       /* pointer to an array of 8 pointers to the last
  75.                            colors assigned to a hardware sprite */ 
  76. WORD *nextlines;        /* pointer to an array of 8 words which are used
  77.                            to keep track of the last lines of each sprite */
  78.  
  79. struct CollTable *collHandler;
  80.  
  81.         /* pointer to the collision handler table */
  82.         /* this is a table of pointers to the routines which should
  83.            be performed when DoCollision senses a collision.  This
  84.            declaration may not be necessary for a basic vsprite with
  85.            no collision detection implemented, but then it makes for
  86.            a complete example */
  87.  
  88. printf("\nEntered ReadyGels\n");
  89.  
  90. lastcolors = (WORD *)AllocMem(sizeof(LONG) * 8,
  91.                         MEMF_PUBLIC+MEMF_CLEAR);
  92. if(lastcolors == NULL)
  93.         printf("\nNo memory for lastcolors\n");
  94.  
  95. /*  *******************************************************************
  96.            In the lastcolors pointer array, the system will store
  97.            a pointer to the color definitions most recently used
  98.            by the system. .... as a reminder, virtual sprites can
  99.            be assigned to any of the real hardware sprites which
  100.            may be available at the time.  The vsprite colors will
  101.            be written into the hardware sprite register set for
  102.            the hardware sprite to which that vsprite is assigned.
  103.            This pointer array contains one pointer to the last
  104.            set of three colors (from the vsprite structure *sprColors)
  105.            for each hardware sprite.  
  106.  
  107.            As the system is scanning to determine which hardware 
  108.            sprite should next be used to represent a vsprite, it
  109.            checks the contents of this array.  If a hardware sprite
  110.            is available and already has been assigned this set of
  111.            colors, no color assignment is needed, and therefore
  112.            no color change instructions will be generated for the
  113.            copper list.
  114.  
  115.            If all vsprites use a different set of sprColors, (pointers
  116.            to sprColors are different for all vsprites), then there
  117.            is a limit of 4 vsprites on a horizontal line.  If, on
  118.            the other hand, you define, lets say 8 vsprites, with
  119.            1 and 2 having the same sprColors, 3 and 4 the same as
  120.            each other, 5 and 6 the same as each other, and 7 and 8
  121.            also having the same vsprite colors, then you will be
  122.            able to have all 8 vsprites on the same horizontal line.
  123.  
  124.            In this case, you will be able to put all 8 vsprites on
  125.            the same horizontal line.  The reason this helps is that
  126.            the system hardware shares the color registers between pairs
  127.            of hardware sprites.  The system thus has enough resources
  128.            to assign all vsprites to hardware sprites in that there
  129.            are 4 color-sets for 8 vsprites, exactly matching the 
  130.            hardware maximum capabilities.
  131.  
  132. *********************************************************************        */
  133.  
  134. nextlines = (WORD *)AllocMem(sizeof(WORD) * 8,
  135.                         MEMF_PUBLIC);
  136. if(nextlines  == NULL)
  137.         printf("\nNo memory for nextlines\n");
  138.  
  139. /*         The nextlines array is used to hold system information about
  140.            "at which line number on the screen is this hardware sprite
  141.            again going to become available to be given a new vsprite to
  142.            display".
  143.  
  144. */
  145.  
  146. collHandler = (struct collTable *)AllocMem(sizeof(struct collTable),
  147.                                                 MEMF_PUBLIC);
  148. if(collHandler  == NULL)
  149.         printf("\nNo memory for collHandler\n");
  150.  
  151. g->nextLine = nextlines;
  152. g->lastColor = lastcolors;
  153. g->collHandler = collHandler;
  154.  
  155. g->leftmost = 0;
  156. g->rightmost = r->BitMap->BytesPerRow * 8 - 1;
  157. g->topmost = 0;
  158. g->bottommost = r->BitMap->Rows - 1;
  159.         
  160.                 /* when any part of the object touches or passes across
  161.                    this boundary, it will cause the boundary collision
  162.                    routine to be called.  This is at smash[0] in the
  163.                    collision handler table and is called only if
  164.                    DoCollision is called.  */
  165.  
  166. g->sprRsrvd = 0xff;
  167.  
  168.                 /* by setting all 1 bits here, it means that there are NO
  169.                    reserved sprites.  The system can freely use all of the 
  170.                    hardware sprites for its own purposes.  The user is not
  171.                    trying to independently use any hardware sprites.  */
  172.  
  173. printf("\nGoing to Link rastport and gelsinfo now\n");
  174.  
  175. r->GelsInfo = g;        /* link together the two structures */
  176. return;
  177. }
  178.  
  179.  
  180. /* This routine cannot be run until the first LoadView(&view) has been 
  181.    executed.  InitGels works with an already active View, so LoadView
  182.    must have been run first */
  183.  
  184.  
  185. NewGelList(myGels)
  186. struct GelsInfo *myGels;
  187. {
  188. struct VSprite *dumSpriteOne =
  189.         (struct VSprite *)AllocMem(sizeof(struct VSprite),
  190.                         MEMF_PUBLIC+MEMF_CLEAR);
  191. struct VSprite *dumSpriteTwo =
  192.         (struct VSprite *)AllocMem(sizeof(struct VSprite),
  193.                         MEMF_PUBLIC+MEMF_CLEAR);
  194.  
  195. InitGels( dumSpriteOne, dumSpriteTwo, myGels );   /* changed from V23 */
  196.  
  197.         /* pointers initialized to the dummy sprites which will be
  198.            used by the system to keep track of the animation system */
  199.  
  200. return;
  201. }
  202.  
  203.  
  204.  
  205. /* use this to get rid of the gels stuff when it is not needed any more */
  206. /* you MUST have allocated the gels info stuff with the routines NewGelList
  207.    and ReadyGels */
  208.  
  209. PurgeGels(g)
  210. struct GelsInfo *g;
  211. {
  212. FreeMem(g->lastColor, sizeof(LONG) * 8);
  213. FreeMem(g->nextLine,  sizeof(WORD) * 8);
  214. FreeMem(g->collHandler, sizeof(struct collTable));
  215. FreeMem(g->gelHead, sizeof(struct VSprite));
  216. FreeMem(g->gelTail, sizeof(struct VSprite));
  217. }
  218.  
  219.  
  220. /* MakeVSprite only creates the vsprite,it doesnt add it to the system list. */
  221. /* (reason it isnt added is that this routine is also used by MakeBob)       */
  222. /* user must do AddVSprite after it is created.  */
  223.  
  224. struct VSprite *MakeVSprite(lineheight,image,colorset,x,y,
  225.                                 width,imagedepth,flags)
  226. SHORT lineheight;       /* how tall is this vsprite? */
  227. WORD *image;            /* where is the vsprite image data, should be
  228.                            twice as many words as the value of lineheight */
  229. WORD *colorset;         /* where is the set of three words which describes
  230.                            the colors that this vsprite can take on? */
  231. SHORT x,y;              /* what is its initial onscreen position? */
  232. SHORT width, imagedepth,flags;
  233. {
  234. struct VSprite *v;      /* make a pointer to the vsprite structure which
  235.                            this routine dynamically allocates */
  236.  
  237. v = (struct VSprite *)AllocMem(sizeof(struct VSprite),MEMF_PUBLIC+MEMF_CLEAR);
  238.  
  239. v->X = x;                       /* establish initial position relative to 
  240.                                    the Display coordinates */
  241. v->Y = y;
  242. v->Flags = flags;               /* is this a vsprite, not a bob? */
  243.  
  244. v->Height = lineheight;         /* user says how high it is */
  245. v->Width = width;               /* a vsprite is always 1 word (16 bits) wide */
  246. v->Depth = imagedepth;          /* a vsprite is always 2 planes deep but if
  247.                                    its being used to make a bob, it may
  248.                                    be deeper .....
  249.  
  250.                                    There are two kinds of depth... the 
  251.                                    depth of the image itself, and the
  252.                                    depth of the playfield into which it
  253.                                    will be drawn.  The image depth says
  254.                                    how much data space will be needed to
  255.                                    store an image if dynamically allocated.
  256.                                    The playfield depth establishes how
  257.                                    much space will be needed to save and
  258.                                    restore the background when a bob is
  259.                                    drawn  */ 
  260.  
  261. v->MeMask = 1;                  /* assume that user at least has a default
  262.                                    boundary collision routine.... bit 1 of
  263.                                    this mask is reserved for boundary    
  264.                                    collision detect during DoCollision(); */
  265. v->HitMask = 1;                 /* assume that user at least has a default
  266.                                    boundary collision routine.... bit 1 of
  267.                                    this mask is reserved for boundary    
  268.                                    collision detect during DoCollision(); */
  269.  
  270. v->ImageData = image;           /* user says where to find the image */
  271.  
  272. v->SprColors = colorset;        /* user says where to find its colors */
  273.  
  274. v->PlanePick = 0x01;
  275. v->PlaneOnOff = 0x00;
  276.  
  277. v->BorderLine = (WORD *)AllocMem((sizeof(WORD)*width),MEMF_PUBLIC);
  278.   
  279.      /* show system where to find a mask which is a squished down version
  280.         of the vsprite (allows for fast horizontal border collision detect */
  281.  
  282. v->CollMask = (WORD *)AllocMem(sizeof(WORD) * lineheight * width, 
  283.                                                 MEMF_PUBLIC);
  284.  
  285.         /* show system where to find the mask which contains a 1 bit 
  286.            for any position in the object in any plane where there 
  287.            is a 1 bit (all planes OR'ed together) */
  288.  
  289. InitMasks(v);   /* create the collMask and borderLine */        
  290. return(v);
  291. }
  292.  
  293.  
  294.  
  295.  
  296. /* deallocate memory which has been allocated by the routine MakeVSprite */
  297.  
  298. DeleteVSprite( v )
  299. struct VSprite *v;
  300. {
  301. FreeMem(v->BorderLine, sizeof(WORD));
  302. FreeMem(v->CollMask, sizeof(WORD) * v->Height);
  303. FreeMem(v, sizeof(struct VSprite));
  304. return;
  305. }
  306.  
  307.  
  308. struct Bob *MakeBob(bitwidth,lineheight,imagedepth,image,pfdepth,
  309.                         planePick,planeOnOff, x,y)
  310. SHORT bitwidth,lineheight,imagedepth,planePick,planeOnOff,x,y,pfdepth;
  311. WORD *image;
  312. {
  313. struct Bob *b;
  314. struct VSprite *v;              
  315. SHORT flags;
  316. SHORT wordwidth;
  317.  
  318. wordwidth = (bitwidth+15)/16;
  319.  
  320. flags = SAVEBACK | OVERLAY;
  321.  
  322. v = MakeVSprite(lineheight,image,NULL,x,y,wordwidth,imagedepth,flags);   
  323.                             /* no color set for bobs */
  324.  
  325.         /* create a vsprite for this bob, will have to be deleted
  326.            later (freed) when this bob gets deleted */
  327.  
  328. b = (struct Bob *)AllocMem(sizeof(struct Bob),MEMF_PUBLIC);
  329.  
  330. v->SprColors = 0;                       /* bobs dont get colorsets */
  331.  
  332. v->PlanePick = planePick;               /* user selects which bit planes
  333.                                            into which the image is to be
  334.                                            drawn */
  335. v->PlaneOnOff = planeOnOff;             /* what happens to the bit planes
  336.                                            into which the image is not 
  337.                                            drawn.  User selected */
  338.  
  339. v->VSBob = b;           /* link together the bob and its vsprite structures */
  340. b->BobVSprite = v;
  341.  
  342.                         /* InitMasks does not preset the imageShadow ... user
  343.                            can select to use the collMask or to create his
  344.                            own version of a shadow (usually the same).  */
  345.                 
  346. b->ImageShadow = v->CollMask;
  347.  
  348. b->SaveBuffer = (WORD *)AllocMem((lineheight*(wordwidth * 2) * pfdepth), 
  349.                                         MEMF_PUBLIC);
  350.  
  351.                 /* tell where to save background */
  352.                 /* must have enough space for as many bitplanes deep as
  353.                    the display into which everything is being drawn */
  354.  
  355. b->Before = 0;  /* when bob first is made, we wont care about priority */
  356. b->After = 0;
  357.  
  358. /* interbob priorities are set such that the earliest defined bobs have
  359.     the lowest priority, last bob defined is on top */
  360.  
  361. b->Flags = 0; /* not part of an animation (BOBISCOMP) and dont keep the
  362.                         image present after bob is removed (SAVEBOB) */ 
  363.  
  364. b->BobComp = 0; /* this is not part of an animation */
  365. b->DBuffer = 0; /* this is not double buffered */
  366.  
  367. return(b);      /* return a pointer to this newly created bob for additional
  368.                         user interaction or for AddBob(b);   */
  369. }
  370.  
  371.  
  372. /* deallocate memory which has been allocated by the routine MakeBob */
  373.  
  374. DeleteBob( b, pfdepth )
  375. struct Bob *b;
  376. SHORT pfdepth;
  377. {
  378. DeleteVSprite(b->BobVSprite);
  379. FreeMem( b->SaveBuffer,(b->BobVSprite->Height*(b->BobVSprite->Width * 2) * pfdepth));
  380. FreeMem( b, sizeof(struct Bob));
  381.  
  382. return;
  383. }
  384.  
  385. /* geltools.c */
  386.  
  387. /* NOTE:  don't try to use vsprites until system software V1.1 becomes
  388.    available.  This tool works to do bobs, but not vsprites until 1.1.
  389.    
  390.    (system bug corrected).
  391.  
  392. */
  393.  
  394. /*
  395. author:  Rob Peck  9/85.  Will eventually cover AnimObs and AnimComps
  396.                           but not yet.
  397.          also note that NewGelList can be merged directly into
  398.          ReadyGels (next version will do so).  No need to have
  399.          separate.
  400.  
  401. */
  402. /* ***********************************************************************
  403.    this file is a collection of tools which are used with the vsprite and
  404.    bob software.  It contains the following:
  405.  
  406.         ReadyGels( *gelsinfo, *rastport )
  407.         NewGelList( *gelsinfo )
  408.         PurgeGels( *gelsinfo )
  409.  
  410.         struct Bob MakeBob(bitwidth,lineheight,imagedepth,*image,pfdepth,
  411.                         planePick,planeOnOff,x,y)
  412.         DeleteBob( &Bob );
  413.  
  414.         struct VSprite MakeVSprite(lineheight,*image,*colorset,x,y,
  415.                 width,imagedepth,flags);       
  416.         DeleteVSprite( &VSprite );
  417.  
  418.  
  419.    ReadyGels sets up the defaults of the gel system by initializing the        
  420.         GelsInfo structure you provide.  It uses information in your
  421.         RastPort structure to establish boundary collision defaults at
  422.         the outer edges of the raster.  It also links together the 
  423.         GelsInfo and the RastPort which you provide.
  424.  
  425.    NewGelList allocates space for two dummy virtual sprite structures
  426.         and calls InitGels.   You must already have run LoadView and
  427.         ReadyGels before NewGelList is called.  
  428.  
  429.    PurgeGels deallocates all memory which ReadyGels and NewGelList have
  430.         allocated.  The system will crash if you have not used these
  431.         routines to allocate the space (you cant deallocate something
  432.         which you havent allocated in the first place).
  433.  
  434.    MakeVSprite allocates enough space for and inits a normal vsprite.
  435.    DeleteVSprite deallocates the memory it used.
  436.  
  437.    MakeBob initializes a standard bob and allocates as much memory as is needed
  438.         for a normal bob and its vsprite structure, links them together.
  439.         To find the associated vsprite, look at the back-pointer (see the
  440.         routine doc itself).
  441.    DeleteBob deallocates the memory it used.
  442.  
  443. *******************************************************************  */
  444.  
  445.  
  446.  
  447. /* user passes a pointer to his GelsInfo structure which he wants to init, 
  448.    along with a pointer to his IVPArgs.  Default init places the topmost
  449.    bottommost etc at the outermost boundaries of the users rastport parameters
  450.     */
  451.  
  452. ReadyGels(g, r)  
  453. struct RastPort *r;
  454. struct GelsInfo *g;
  455. {
  456.  
  457. WORD *lastcolors;       /* pointer to an array of 8 pointers to the last
  458.                            colors assigned to a hardware sprite */ 
  459. WORD *nextlines;        /* pointer to an array of 8 words which are used
  460.                            to keep track of the last lines of each sprite */
  461.  
  462. struct CollTable *collHandler;
  463.  
  464.         /* pointer to the collision handler table */
  465.         /* this is a table of pointers to the routines which should
  466.            be performed when DoCollision senses a collision.  This
  467.            declaration may not be necessary for a basic vsprite with
  468.            no collision detection implemented, but then it makes for
  469.            a complete example */
  470.  
  471. printf("\nEntered ReadyGels\n");
  472.  
  473. lastcolors = (WORD *)AllocMem(sizeof(LONG) * 8,
  474.                         MEMF_PUBLIC+MEMF_CLEAR);
  475. if(lastcolors == NULL)
  476.         printf("\nNo memory for lastcolors\n");
  477.  
  478. /*  *******************************************************************
  479.            In the lastcolors pointer array, the system will store
  480.            a pointer to the color definitions most recently used
  481.            by the system. .... as a reminder, virtual sprites can
  482.            be assigned to any of the real hardware sprites which
  483.            may be available at the time.  The vsprite colors will
  484.            be written into the hardware sprite register set for
  485.            the hardware sprite to which that vsprite is assigned.
  486.            This pointer array contains one pointer to the last
  487.            set of three colors (from the vsprite structure *sprColors)
  488.            for each hardware sprite.  
  489.  
  490.            As the system is scanning to determine which hardware 
  491.            sprite should next be used to represent a vsprite, it
  492.            checks the contents of this array.  If a hardware sprite
  493.            is available and already has been assigned this set of
  494.            colors, no color assignment is needed, and therefore
  495.            no color change instructions will be generated for the
  496.            copper list.
  497.  
  498.            If all vsprites use a different set of sprColors, (pointers
  499.            to sprColors are different for all vsprites), then there
  500.            is a limit of 4 vsprites on a horizontal line.  If, on
  501.            the other hand, you define, lets say 8 vsprites, with
  502.            1 and 2 having the same sprColors, 3 and 4 the same as
  503.            each other, 5 and 6 the same as each other, and 7 and 8
  504.            also having the same vsprite colors, then you will be
  505.            able to have all 8 vsprites on the same horizontal line.
  506.  
  507.            In this case, you will be able to put all 8 vsprites on
  508.            the same horizontal line.  The reason this helps is that
  509.            the system hardware shares the color registers between pairs
  510.            of hardware sprites.  The system thus has enough resources
  511.            to assign all vsprites to hardware sprites in that there
  512.            are 4 color-sets for 8 vsprites, exactly matching the 
  513.            hardware maximum capabilities.
  514.  
  515. *********************************************************************        */
  516.  
  517. nextlines = (WORD *)AllocMem(sizeof(WORD) * 8,
  518.                         MEMF_PUBLIC);
  519. if(nextlines  == NULL)
  520.         printf("\nNo memory for nextlines\n");
  521.  
  522. /*         The nextlines array is used to hold system information about
  523.            "at which line number on the screen is this hardware sprite
  524.            again going to become available to be given a new vsprite to
  525.            display".
  526.  
  527. */
  528.  
  529. collHandler = (struct collTable *)AllocMem(sizeof(struct collTable),
  530.                                                 MEMF_PUBLIC);
  531. if(collHandler  == NULL)
  532.         printf("\nNo memory for collHandler\n");
  533.  
  534. g->nextLine = nextlines;
  535. g->lastColor = lastcolors;
  536. g->collHandler = collHandler;
  537.  
  538. g->leftmost = 0;
  539. g->rightmost = r->BitMap->BytesPerRow * 8 - 1;
  540. g->topmost = 0;
  541. g->bottommost = r->BitMap->Rows - 1;
  542.         
  543.                 /* when any part of the object touches or passes across
  544.                    this boundary, it will cause the boundary collision
  545.                    routine to be called.  This is at smash[0] in the
  546.                    collision handler table and is called only if
  547.                    DoCollision is called.  */
  548.  
  549. g->sprRsrvd = 0xff;
  550.  
  551.                 /* by setting all 1 bits here, it means that there are NO
  552.                    reserved sprites.  The system can freely use all of the 
  553.                    hardware sprites for its own purposes.  The user is not
  554.                    trying to independently use any hardware sprites.  */
  555.  
  556. printf("\nGoing to Link rastport and gelsinfo now\n");
  557.  
  558. r->GelsInfo = g;        /* link together the two structures */
  559. return;
  560. }
  561.  
  562.  
  563. /* This routine cannot be run until the first LoadView(&view) has been 
  564.    executed.  InitGels works with an already active View, so LoadView
  565.    must have been run first */
  566.  
  567.  
  568. NewGelList(myGels)
  569. struct GelsInfo *myGels;
  570. {
  571. struct VSprite *dumSpriteOne =
  572.         (struct VSprite *)AllocMem(sizeof(struct VSprite),
  573.                         MEMF_PUBLIC+MEMF_CLEAR);
  574. struct VSprite *dumSpriteTwo =
  575.         (struct VSprite *)AllocMem(sizeof(struct VSprite),
  576.                         MEMF_PUBLIC+MEMF_CLEAR);
  577.  
  578. InitGels( dumSpriteOne, dumSpriteTwo, myGels );   /* changed from V23 */
  579.  
  580.         /* pointers initialized to the dummy sprites which will be
  581.            used by the system to keep track of the animation system */
  582.  
  583. return;
  584. }
  585.  
  586.  
  587.  
  588. /* use this to get rid of the gels stuff when it is not needed any more */
  589. /* you MUST have allocated the gels info stuff with the routines NewGelList
  590.    and ReadyGels */
  591.  
  592. PurgeGels(g)
  593. struct GelsInfo *g;
  594. {
  595. FreeMem(g->lastColor, sizeof(LONG) * 8);
  596. FreeMem(g->nextLine,  sizeof(WORD) * 8);
  597. FreeMem(g->collHandler, sizeof(struct collTable));
  598. FreeMem(g->gelHead, sizeof(struct VSprite));
  599. FreeMem(g->gelTail, sizeof(struct VSprite));
  600. }
  601.  
  602.  
  603. /* MakeVSprite only creates the vsprite,it doesnt add it to the system list. */
  604. /* (reason it isnt added is that this routine is also used by MakeBob)       */
  605. /* user must do AddVSprite after it is created.  */
  606.  
  607. struct VSprite *MakeVSprite(lineheight,image,colorset,x,y,
  608.                                 width,imagedepth,flags)
  609. SHORT lineheight;       /* how tall is this vsprite? */
  610. WORD *image;            /* where is the vsprite image data, should be
  611.                            twice as many words as the value of lineheight */
  612. WORD *colorset;         /* where is the set of three words which describes
  613.                            the colors that this vsprite can take on? */
  614. SHORT x,y;              /* what is its initial onscreen position? */
  615. SHORT width, imagedepth,flags;
  616. {
  617. struct VSprite *v;      /* make a pointer to the vsprite structure which
  618.                            this routine dynamically allocates */
  619.  
  620. v = (struct VSprite *)AllocMem(sizeof(struct VSprite),MEMF_PUBLIC+MEMF_CLEAR);
  621.  
  622. v->X = x;                       /* establish initial position relative to 
  623.                                    the Display coordinates */
  624. v->Y = y;
  625. v->Flags = flags;               /* is this a vsprite, not a bob? */
  626.  
  627. v->Height = lineheight;         /* user says how high it is */
  628. v->Width = width;               /* a vsprite is always 1 word (16 bits) wide */
  629. v->Depth = imagedepth;          /* a vsprite is always 2 planes deep but if
  630.                                    its being used to make a bob, it may
  631.                                    be deeper .....
  632.  
  633.                                    There are two kinds of depth... the 
  634.                                    depth of the image itself, and the
  635.                                    depth of the playfield into which it
  636.                                    will be drawn.  The image depth says
  637.                                    how much data space will be needed to
  638.                                    store an image if dynamically allocated.
  639.                                    The playfield depth establishes how
  640.                                    much space will be needed to save and
  641.                                    restore the background when a bob is
  642.                                    drawn  */ 
  643.  
  644.